package com.eshopkeeper.core.support.ldap;


import org.springframework.ldap.core.AttributesMapper;

import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;


/**
 * ClassName: ErrorInfoAttributesMapper
 * @Description: ldap属性匹配实体
 * @author chenshufeng
 * @date 2017-2-9
 */
public class ErrorInfoAttributesMapper implements AttributesMapper<ErrorInfo> {

	@Override
	public ErrorInfo mapFromAttributes(Attributes attributes)
			throws NamingException {
		ErrorInfo errorInfo = new ErrorInfo();
        Attribute errorCode = attributes.get("errorCode");
        Attribute errorMsg = attributes.get("errorMsg");

        errorInfo.setErrorCode(String.valueOf(String.valueOf(errorCode).replace("errorCode: ","")));
        errorInfo.setErrorMsg(String.valueOf(String.valueOf(errorMsg).replace("errorMsg: ","")));

        return errorInfo;
	}

}